package com.example.pan.lock.redis;

import com.example.pan.lock.core.LockConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.redis.util.RedisLockRegistry;
import org.springframework.integration.support.locks.LockRegistry;

/**
 * @Author: invictusQAQ
 * @Date: 2023-12-12-20:24
 * @Description:
 */
@Configuration
@Slf4j
public class RedisLockConfig {

    @Bean
    public LockRegistry redisLockRegistry(RedisConnectionFactory redisConnectionFactory){
        RedisLockRegistry lockRegistry = new RedisLockRegistry(redisConnectionFactory,
                LockConstants.R_PAN_LOCK);
        log.info("redis lock is loaded successfully!");
        return lockRegistry;
    }

}
